# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=rtl88x2bu-src
_modname=${pkgname%-src}
_projname=RTL88x2BU-Linux-Driver
pkgver=5.13.1_git20230711
# No git tags in the repo, but they use version numbers.
_gitrev=12cfcd8cd8ec7115158df3d223510435541ddc32
pkgrel=0
pkgdesc="Kernel module for Realtek rtl88x2bu WiFi chipset (sources, AKMS)"
url="https://github.com/RinCat/RTL88x2BU-Linux-Driver"
arch="noarch"
license="GPL-2.0"
source="https://github.com/RinCat/RTL88x2BU-Linux-Driver/archive/$_gitrev/$_projname-$_gitrev.tar.gz"
builddir="$srcdir/$_projname-$_gitrev"
options="!check"  # sources only

prepare() {
	default_prepare

	cat >AKMBUILD <<-EOF
	modname=$_modname
	modver=$pkgver-r$pkgrel
	built_modules='88x2bu.ko'

	# This module doesn't support building outside of its source dir. :(
	build() {
		cp -r "\$srcdir"/* .
		make \$MAKEFLAGS KVER="\$kernel_ver" KSRC="\$kernel_srcdir"
	}
	EOF
}

package() {
	mkdir -p "$pkgdir"/usr/src/$_modname-$pkgver

	cp -pr ./*/ AKMBUILD LICENSE Makefile halmac.mk rtl8822b.mk \
		"$pkgdir"/usr/src/$_modname-$pkgver/
}

sha512sums="
98f5c47fc6c37acdc80cc6662198e5e90ff3222e21755b0ed43a608a63fc4e91432e3cb659ad4399228c8a99945ff4138c9b587b95d34ca9da2e068c1fa49b58  RTL88x2BU-Linux-Driver-12cfcd8cd8ec7115158df3d223510435541ddc32.tar.gz
"
